package kassiopeia.gui

import org.apache.activemq.command.ActiveMQObjectMessage;
import kassiopeia.commons.io.Message;

class MessageSenderService {

    private static final String QUEUE_PREFIX = "AGENT_QUEUE_ID"
    private static final String BROADCAST_TOPIC = "BROADCAST_TOPIC"
    static transactional = true
    def jmsService

    def send(Message message, String to) {
        jmsService.send(queue: agentQueue(to), message)
    }

    def broadcaset(Message message) {
        jmsService.send(topic: BROADCAST_TOPIC, message)
    }

    private def buildJmsMessage(Message message) {
        ActiveMQObjectMessage jmsMessage = new ActiveMQObjectMessage()
        jmsMessage.setObject(message)
    }

    private def agentQueue(String agentId) {
        return QUEUE_PREFIX + agentId
    }
}
